package com.mgm.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.mgm.country.service.CountryService;
import com.mgm.dto.CountryItemDto;
import com.mgm.result.IResult;

@Controller
@RequestMapping("/countries")
public class CountryController {
	
	@Autowired
	private CountryService countryService;
	
	@RequestMapping(method = RequestMethod.GET)
	public ResponseEntity<IResult<CountryItemDto>> listUsers(HttpServletRequest request, HttpServletResponse response) {
		List<String> list = countryService.selectShort();
		CountryItemDto cid = new CountryItemDto(list);
		
		IResult<CountryItemDto> result = IResult.success(cid);
		
		return new ResponseEntity<IResult<CountryItemDto>>(result, HttpStatus.OK);
	}
}
